package com.study.rabbitmq;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.UnsupportedEncodingException;


public class ConsumerApp {
    public static void main(String[] args) throws UnsupportedEncodingException {

        AbstractApplicationContext context =
                new ClassPathXmlApplicationContext("spring-rabbitmq.xml");
        RabbitTemplate rabbitTeplate = context.getBean(RabbitTemplate.class);

        Message message = rabbitTeplate.receive("queue.yy");



        System.out.println(new String(message.getBody(), message.getMessageProperties().getContentEncoding()));

        context.close();

    }
}
